import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'

import { AnnexButton } from '../Common/options'

import { Progress, Tag } from 'antd'

const { hostname } = window.location

const independenceList = {
    'jtgjadmin.ljkjkf.com': 'organizationUuid',
    'jtgjadmin.hljsjtgj.com': 'organizationUuid',
}

export const ListHttqContract = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        hideInSearch: true,
        independenceSet: {
            title: '组织机构',
            url: 'getOrgTree',
            data: { IsByUserUuid: 1 },
            type: 'TableNavTree001',
            all: true,
        },
        independence: independenceList[hostname],
        hideInSearch: true,
        options: [
            <AnnexButton
                OptionsEvent={OptionsEvent}
                key="thr"
                url="https://image.ljkjkf.com/intellisiteSystem_TieKe/jtgj/3.png"
                title="获取OA合同"
                type="primary"
                icon="a01"
            />,
            <AnnexButton
                OptionsEvent={OptionsEvent}
                key="thr"
                url="123.png"
                title="批量识别提取合同"
                type="primary"
                icon="a02"
                readonly={true}
            />,
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'bh',
                title: '编号',
                valueType: 'input',
                width: 80,
            },
            {
                dataIndex: 'wjmc',
                title: '文件名称',
                valueType: 'input',
                width: 160,
            },
            {
                dataIndex: 'czlx',
                title: '操作类型',
                valueType: 'input',
                width: 80,
            },
            {
                dataIndex: 'zt',
                title: '状态',
                valueType: 'input',
                width: 120,
                render: (_, e) => {
                    const { zt, jdt } = e
                    const TagMapping = {
                        已提取: (
                            <>
                                <Tag color="success">已提取</Tag>
                                <Progress percent={jdt * 100} />
                            </>
                        ),
                        提取中: (
                            <>
                                <Tag color="processing">提取中</Tag>
                                <Progress percent={jdt * 100} status="active" />
                            </>
                        ),
                        未提取: (
                            <>
                                <Tag color="error">未提取</Tag>
                                <Progress percent={jdt * 100} status="exception" />
                            </>
                        ),
                    }

                    return <div style={{ display: 'flex' }}>{TagMapping[zt]}</div>
                },
            },
            {
                dataIndex: 'updatetime',
                title: '更新时间',
                valueType: 'input',
                width: 120,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 80,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <AnnexButton
                            OptionsEvent={OptionsEvent}
                            key="thr"
                            url="https://image.ljkjkf.com/intellisiteSystem_TieKe/jtgj/3.png"
                            title="查看风险"
                            readonly={true}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
